#!/usr/bin/env python
#coding:utf-8
########################################################################
# File Name: getImage.py
# Purpose:  
# Usage: getImage.py  
# Author: Weidongq
# Mail: 361970327@qq.com 
# Created Time: Thu 2017-01-05 14:33
########################################################################

import re
import urllib
import sys
def getHtmlCode(htmlUrl):
    htmlToRead = urllib.urlopen(htmlUrl)
    htmlCode = htmlToRead.read()
    return htmlCode

def getImage(htmlCode):
#    imgPatt = r'src="(.*?\.jpg)" bdwater'
    imgPatt = r'src="(.*?\.jpg)"'
    imgre = re.compile(imgPatt)
    imgurl = imgre.findall(htmlCode)
    x = 1
    for img in imgurl:
#        urllib.urlretrieve(img,"%s.jpg" %x)
        print img
        x+=1


#htmlCode = getHtmlCode('http://tieba.baidu.com/p/4479988184')
htmlCode = getHtmlCode(sys.argv[1])

getImage(htmlCode)


